<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="file" id="file" />
    <div id="car-list"></div>
    <script src="./jquery-2.2.4.js"></script>
    <script src="https://cdn.bootcss.com/xlsx/0.14.3/xlsx.full.min.js"></script>
    <script>
        // js读取解析Excel
        // 定义一个carData,用来保存读取到的数据
        var excelData;
        $(document).ready(function () {

            var wb; //读取完成的数据
            var rABS = false; //是否将文件读取为二进制字符串

            function fixdata(data) { //文件流转BinaryString
                var o = "",
                    l = 0,
                    w = 10240;
                for (; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data
                    .slice(l * w, l * w + w)));
                o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
                return o;
            }

            $("#file").change(function () {
                if (!this.files) {
                    return;
                }
                var f = this.files[0];
                var reader = new FileReader();
                reader.onload = function (e) {
                    var data = e.target.result;
                    if (rABS) {
                        wb = XLSX.read(btoa(fixdata(data)), {
                            type: 'base64'
                        });
                    } else {
                        wb = XLSX.read(data, {
                            type: 'binary'
                        });
                    }

                    // carData就是我们需要的JSON数据
                 
                    excelData = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
                    console.log(excelData);
                };
                if (rABS) {
                    reader.readAsArrayBuffer(f);
                } else {
                    reader.readAsBinaryString(f);
                }
            })

        });

    </script>
</body>

</html>